﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using OhioState.Graphics;
using OhioState.AssetManaged;

namespace OhioState.Controls
{
    public partial class LayerConfigDialog : Form
    {
        public LayerConfigDialog(ILayer layer)
        {
            this.layer = layer;
            InitializeComponent();
            this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            layerConfigControl1.SetLayer(layer);
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            layer.Camera = this.layerConfigControl1.Camera;
            layer.FrameBuffer = this.layerConfigControl1.FrameBuffer;
            Close();
        }

        private void newFboButton_Click(object sender, EventArgs e)
        {
            FBOConfigDialog fboDialog = new FBOConfigDialog();
            if (fboDialog.ShowDialog() == DialogResult.OK)
            {
                IFrameBufferObject fbo = fboDialog.CreateFBO();
                IAssetManaged asset = fbo as IAssetManaged;
                if (asset != null)
                {
                    AssetManager.Instance.Add(asset);
                }
            }
        }

        private ILayer layer;
    }
}
